package ynu.sxp.demoapp.product.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.persistence.EntityNotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ynu.sxp.demoapp.product.dto.ProductRO;
import ynu.sxp.demoapp.product.entity.ProductEntity;
import ynu.sxp.demoapp.product.service.ProductService;

import java.util.List;
import java.util.UUID;

@RestController
@Tag(name = "Product", description = "商品" )
@RequestMapping("/api/product")
public class ProductController {
    private final ProductService productService;

    public ProductController(ProductService productService) {
        this.productService = productService;
    }


    @GetMapping("info")
    @Operation(summary = "获取商品信息", description = "获取所有商品信息")
    public List<ProductRO> getProductInfo() {
        return productService.getAllProducts();
    }

    @GetMapping("detail")
    @Operation(summary = "获取商品详情", description = "获取当前商品详情")
    public ProductRO getProductInfoById(@RequestParam("id") UUID id) {
        return productService.getProduct(id);
    }

}
